package com.example.index.controller;


import com.example.index.entity.*;
import com.example.index.service.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class SchoolInfoController {

    @Resource
    private NewGoodService newGoodService;
    @Resource
    private ProfessionService professionService;
    @Resource
    private PedagogyService pedagogyService;
    @Resource
    private SchoolCooperationPicturesService schoolCooperationPicturesService;
    @Resource
    private SourceService sourceService;

    @GetMapping("schoolInfo")
    public String schoolInfo(ModelMap modelMap){

        Page<NewGood> newGoods = newGoodService.queryByPage(new NewGood(), PageRequest.of(0, 1000));
        List<NewGood> newGoodList = newGoods.getContent();
        modelMap.addAttribute("newGoodList",newGoodList);

        Page<Profession> professions = professionService.queryByPage(new Profession(), PageRequest.of(0, 1000));
        List<Profession> professionsList = professions.getContent();
        modelMap.addAttribute("professionsList", professionsList);

        Page<Pedagogy> pedagogies = pedagogyService.queryByPage(new Pedagogy(), PageRequest.of(0, 1000));
        List<Pedagogy> pedagogyList = pedagogies.getContent();
        modelMap.addAttribute("pedagogyList",pedagogyList);

        Page<SchoolCooperationPictures> schoolEnvironments = schoolCooperationPicturesService.queryByPage(new SchoolCooperationPictures(), PageRequest.of(0, 1000));
        List<SchoolCooperationPictures> schoolEnvironmentsList = schoolEnvironments.getContent();
        modelMap.addAttribute("schoolEnvironmentsList",schoolEnvironmentsList);

        /**
         * 响应视频
         */
        Page<Source> sources= sourceService.queryByPage(new Source(), PageRequest.of(0, 1000));
        List<Source> sourceList = sources.getContent();
//        System.out.println(sourceList);
        modelMap.addAttribute("sourceList",sourceList);
        return "schoolInfo";
    }
}
